// #include <dbg.h>

#include <algorithm>
#include <cassert>
#include <vector>

using namespace std;

class Solution {
public:
    vector<int> successfulPairs(vector<int>& spells,
                                vector<int>& potions,
                                long long success) {
        sort(potions.begin(), potions.end());

        vector<int> res;
        for (int& spell : spells) {
            long long index = (success - 1) / spell;
            res.push_back(potions.size() -
                          (upper_bound(potions.begin(), potions.end(), index) -
                           potions.begin()));
        }
        return res;
    }
};

int main() {
    Solution s;

    vector<int> spells1{5, 1, 3}, positions1{1, 2, 3, 4, 5}, res1{4, 0, 3};
    vector<int> spells2{3, 1, 2}, positions2{8, 5, 8}, res2{2, 0, 2};

    assert(s.successfulPairs(spells1, positions1, 7) == res1);
    assert(s.successfulPairs(spells2, positions2, 16) == res2);

    return 0;
}